﻿<%@ page import="java.util.*" %>
<%@ page import="com.byjyate.rssdreamwork.*" %>
<br>
<%
	String domain = request.getRequestURL().toString().replace("settings/editrss.jsp", "");
    try {
    	String rssId = request.getParameter("rssid");
		RssInfoRepository rssInfoRepo = new RssInfoRepository();
		RssInfo rssInfo = rssInfoRepo.getRssInfo(rssId);
		if (rssInfo != null) {
			String transformCommands = "";
			for (String command : rssInfo.getTransformCommandList())
				transformCommands += command + "\n";
%>
			<form action="/settings/editrss" method="post">
				<p>
					<p>RSS 地址：<%= domain %>rss?rssid=<%= rssInfo.getRssId() %></p>
				</p>
				<input type="hidden" name="rssid" value="<%= rssInfo.getRssId() %>" />
				<p>
					<label for="title">标题：</label>
					<input type="text" name="title" value="<%= rssInfo.getTitle() %>" />
				</p>
				<p>
					<label for="link">链接：</label>
					<input type="text" name="link" value="<%= rssInfo.getLink() %>" />
				</p>
				<p>
					<label for="description">描述：</label>
					<input type="text" name="description" value="<%= rssInfo.getDescription() %>" />
				</p>
				<p>所有者：<%= rssInfo.getOwner() %></p>
				<p>
					<label for="transformcommands">处理指令：</label>
				</p>
				<textarea name="transformcommands" cols="70" rows="10"><%= transformCommands %></textarea>
				<p>
					<input type="submit" value="提交" />
				</p>
			</form>
<%
		}
		else {
%>
			<h1>抱歉，该 RSS 不存在</h1>
<%
		}
	} catch (Exception e) {
%>
		<h1>抱歉，发生错误</h1>
<%
	}
%>